<?php
   session_start();
    include_once 'class/user.php';

    $login = $_POST['myusername'];
    $pswd = $_POST['mypassword'];
    // To protect MySQL injection (more detail about MySQL injection)
    $login = stripslashes($login);
    $pswd = stripslashes($pswd);

    $user = new User;
    $user->setLogin($login) ;
    $user->setPasswd($pswd);
    try{
       $user = $user->login();
    }catch(Exception $exc){print_r($exc);}

    $_SESSION['mail'] = $user->getLogin();
    $_SESSION['name'] = $user->getName();
 //   print("test1".$_SESSION['mail']);
 //   print("test2".$_SESSION['name']);
    
   // @header("Location :index.php");
    include_once 'header.php';
    include_once 'index.php';

include 'footer.php';
?>
